<template>
    <div class="app-container" ref="content">
        <div style="text-align: center;padding: 10px">任务《{{enterpriseTaskInfo.taskName}}》-详情信息</div>
        <el-row :gutter="10">
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                <el-form :model="enterpriseTaskInfo" ref="enterpriseTaskInfo" label-width="150px">
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
                            <el-form-item label="任务名称:" prop="taskName">
                                {{ enterpriseTaskInfo.taskName }}
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
                            <el-form-item label="执行企业:" prop="enterpriseName">
                                {{ enterpriseTaskInfo.enterpriseName  }}
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
                            <el-form-item label="任务状态:" prop="status">
                                {{ enterpriseTaskInfo.status | taskStatus }}
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
                            <el-form-item label="反馈内容" prop="feedBack">
                                {{ enterpriseTaskInfo.feedBack }}
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
                            <el-form-item label="开始时间:" prop="startTime">
                                {{ enterpriseTaskInfo.startTime  | dateFormat}}
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
                            <el-form-item label="结束时间:" prop="endTime">
                                {{ enterpriseTaskInfo.endTime | dateFormat}}
                            </el-form-item>
                        </el-col>
                    </el-col>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import {getEnterpriseTaskInfoVo} from "@/api/enterpriseTask";
import {getInEnterpriseList} from "@/api/enterprise";

export default {
    name: "enterpriseTaskInfo",
    data(){
        return{

            enterpriseTaskInfo:{
                status:0,
            },
            searchForm:{
                deleted:false,
                taskId:this.$route.params.ucId
            },
            enterpriseList:[]

        }
    },
    created() {
        this.$nextTick(() => {
            this.getEnterpriseTaskInfoVo(this.$route.params.ucId)
        });
        this.getInEnterpriseList();
    },
    methods:{
        handleSearch(){
            this.$refs.taskInfoTable.getTableData(1)
        },
        handleEdit(val){
            this.$router.push("/enterpriseTask/taskInfoEdit/"+val.ucId)
        },
        getEnterpriseTaskInfoVo(val){
            //获取企业信息数据
            let loadingInstance = this.$loading({
                target:this.$refs.content,
                text:'数据加载中'
            });
            getEnterpriseTaskInfoVo({ucId:val}).then(res=>{
                console.log(res)

                this.enterpriseTaskInfo = res.data

                loadingInstance.close()
                this.$notify.success({
                    title: '成功',
                    message: "获取企业任务信息成功"
                })
            }).catch(error=>{
                console.log(error)
                loadingInstance.close()
                this.$notify.error({
                    title: '失败',
                    message: "获取企业任务信息失败"
                })
            })
        },
        getInEnterpriseList(){
            getInEnterpriseList({deleted:false}).then(res=>{
                this.enterpriseList = res.data
            }).catch(error=>{

            })
        }

    },
    filters:{
        taskTypeStatus(val){
            let taskType ="";
            switch (val){
                case 0:
                    taskType = "消防演练";
                    break;
                case 1:
                    taskType = "巡检任务";
                    break;
                case 2:
                    taskType = "培训任务";
                    break;
                case 3:
                    taskType = "巡检任务";
                    break;
                default:
                    break;
            }
            return taskType;

        },
        taskStatus(val){
            let status ="";
            switch (val){
                case 0:
                    status = "已下发";
                    break;
                case 1:
                    status = "进行中";
                    break;
                case 2:
                    status = "延迟";
                    break;
                case 3:
                    status = "已完成";
                    break;
                case 4:
                    status = "已取消";
                    break;
                default:
                    break;
            }
            return status;
        }
    }

}
</script>
